package cn.hughie.thread;


/**
 * @author yuh
 * @date 2018/5/24 13:30
 * @description 单例计算器
 */
public class Calculator {
    private Calculator() {
    }

    private static class ResourceHolder {
        public static final Calculator resource = new Calculator();
    }

    public static Calculator getInstance() {
        return ResourceHolder.resource;
    }

    public int compute(int a) {
        //假如是非常大的计算量或者IO
        return a + 1;
    }
}
